#ifndef __STORM_LIGHTNING__
#define __STORM_LIGHTNING__

#include "EffectBase.h"
#include "AnimationSet.h"

using namespace Ogre;
class StormLightning: public EffectBase
{

public:

	StormLightning();
	~StormLightning();



	Vector2 mScreenPosition;//screen coordinates for storm center

	virtual void load(); 
	virtual void update(Ogre::Real timeSinceLast);


	virtual void begin();
	virtual void stop();

	virtual void eventMouseMove(int _x, int _y, int _xRel, int _yRel, bool isButtonDown);
	virtual void eventMouseRelease(int _xx, int _yy);
	virtual void stateMouseDown(int _x, int _y, int _xRel, int _yRel, bool isButtonDown);

	bool hasBegun();

	void setPostionViaCloud(Vector3 pos, Real _height);
	void setOriginalCenter(Vector2 oc );

protected:

	Vector3 cloudPosition;
	Vector3 sparkPosition;
	Vector3 lightningPosition;

	Ogre::SceneNode *mCloudNode;
	Ogre::SceneNode *mSparkNode;
	AnimationSet *m_pLightningAS;

	Real height;


	//game logic and parameters related
	Real timeSinceStartCloud;
	Real sparkTriggerTime;
	Real lightningTriggerTime;
	Real wholeInterval;
	//screen coordinates
	Vector2 originalCenter;
	//squared
	Real allowedDistance2;
	Real allowedDistance;

	Real speedOfCenterMoving;

	std::vector<Vector2> cloudPosCollection;
	Vector2 cloudAveragePos;

	bool lightningHasRegisterVanish;
private:
};







#endif